﻿<Window x:Class="BOL.Apps.GeneNetworkBrowser.Windows.SubNetworkWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:converters="clr-namespace:BOL.Apps.GeneNetworkBrowser.Converters"
        xmlns:control="clr-namespace:BOL.Apps.GeneNetworkBrowser.Controls"
        WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        Title="SubNetwork - Analysis" Height="394" Width="480">
    <Window.Resources>
        <converters:PopulationSizeConverter x:Key="PopulationSizeConverter" />
        <converters:SelectedIndexToVisibilityConverter x:Key="SelectedIndexToVisibilityConverter" />
    </Window.Resources>
    <StackPanel Margin="5">
        <TextBlock TextWrapping="Wrap">SubNetwork analysis yields a subset of networks lying on a given network.</TextBlock>
        <ScrollViewer VerticalScrollBarVisibility="Visible" Height="294">
            <StackPanel>
                <GroupBox Header="Network">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap" Margin="5">Assign a network source to start with:</TextBlock>
                        <DockPanel>
                            <TextBlock VerticalAlignment="Center" Margin="20,0,5,0" Text="Project:" />
                            <ComboBox Name="_cbProjects" ItemsSource="{Binding Projects}" DisplayMemberPath="Name" SelectedValuePath="Networks" Margin="0,0,5,0" Width="120" SelectedIndex="0" />
                            <TextBlock VerticalAlignment="Center" Margin="10,0,5,0" Text="Network:" />
                            <ComboBox Name="_cbNetworks" ItemsSource="{Binding ElementName=_cbProjects, Path=SelectedValue, Mode=OneWay}" DisplayMemberPath="Name" SelectedValuePath="VertexCount" SelectedIndex="0" />
                        </DockPanel>
                    </StackPanel>
                </GroupBox>
                <GroupBox>
                    <GroupBox.Header>
                        <ComboBox Name="_cbAlgorithmType">
                            <ComboBoxItem IsSelected="True">Genetic algorithm</ComboBoxItem>
                            <ComboBoxItem ToolTip="Enumerate all possible sub-networks...">Exhaustive search</ComboBoxItem>
                        </ComboBox>
                    </GroupBox.Header>
                    <StackPanel>
                        <DockPanel Margin="5" Visibility="{Binding SelectedIndex, ElementName=_cbAlgorithmType, Converter={StaticResource SelectedIndexToVisibilityConverter}}">
                            <TextBlock VerticalAlignment="Center" TextWrapping="Wrap">Search for highly probable sub-networks of given size.</TextBlock>
                        </DockPanel>
                        <DockPanel Margin="20,5,0,0" Visibility="{Binding SelectedIndex, ElementName=_cbAlgorithmType, Converter={StaticResource SelectedIndexToVisibilityConverter}}">
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0">Random seed:</TextBlock>
                            <TextBox Name="_tbRandomSeed" Text="{Binding Source={x:Static sys:DateTime.Now}, Path=Millisecond, Mode=OneWay}" Width="30" Margin="0,0,5,0" TextAlignment="Right" />
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0">Tolerance:</TextBlock>
                            <TextBox Name="_tbTolerance" Text="1e-8" Width="35" Margin="0,0,5,0" TextAlignment="Right" />
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0" ToolTip="The number of iterations"># iterations</TextBlock>
                            <Slider Name="_sliderNumberOfIterations" Minimum="1" Maximum="10000" Width="70" TickFrequency="10" IsSnapToTickEnabled="True" Value="100" Margin="0,0,2,0"/>
                            <TextBox Name="_tbNumberOfIterations" Text="{Binding ElementName=_sliderNumberOfIterations, Path=Value}" Width="48" TextAlignment="Right"></TextBox>
                        </DockPanel>
                        <DockPanel Margin="20,5,0,0" Visibility="{Binding SelectedIndex, ElementName=_cbAlgorithmType, Converter={StaticResource SelectedIndexToVisibilityConverter}}">
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0">Population size:</TextBlock>
                            <Slider Name="_sliderPopulationSize" Minimum="1" Maximum="100000" Width="65" Value="100" TickFrequency="1" Margin="0,0,5,0"/>
                            <TextBox Name="_tbPopulationSize" Text="{Binding ElementName=_sliderPopulationSize, Path=Value}" Width="40" Margin="0,0,15,0" TextAlignment="Right" />
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0"># elites:</TextBlock>
                            <Slider Name="_sliderNumberOfElites" Minimum="0" Maximum="10000" Width="65" Value="100" TickFrequency="1" Margin="0,0,5,0"/>
                            <TextBox Name="_tbNumberOfElites" Text="{Binding ElementName=_sliderNumberOfElites, Path=Value}" Width="40" TextAlignment="Right" />
                        </DockPanel>
                        <WrapPanel Margin="20,5,0,0">
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0">Crossover rate:</TextBlock>
                            <Slider Name="_sliderCrossoverRate" Minimum="0" Maximum="1" Width="65" Value="0.8" Margin="0,0,5,0"/>
                            <TextBox Name="_tbCrossoverRate" Text="{Binding ElementName=_sliderCrossoverRate, Path=Value}" Width="40" Margin="0,0,15,0" TextAlignment="Right" />
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0">Mutation rate:</TextBlock>
                            <Slider Name="_sliderMutationRate" Minimum="0" Maximum="1" Width="65" Value="0.1" Margin="0,0,5,0"/>
                            <TextBox Name="_tbMutationRate" Text="{Binding ElementName=_sliderMutationRate, Path=Value}" Width="40" TextAlignment="Right" />
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0">Selection method:</TextBlock>
                            <ComboBox Name="_cbSelectionMethod">
                                <ComboBoxItem IsSelected="True">Roullet Wheel</ComboBoxItem>
                                <ComboBoxItem>Rank</ComboBoxItem>
                            </ComboBox>
                        </WrapPanel>
                        <DockPanel Margin="20,5,0,0">
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0"># of nodes in subnetwork: Min</TextBlock>
                            <Slider Name="_sliderMinNodes" Minimum="3" Maximum="{Binding ElementName=_cbNetworks, Path=SelectedValue, Converter={StaticResource PopulationSizeConverter}}" Width="65" TickFrequency="1" IsSnapToTickEnabled="True" Value="3" Margin="0,0,5,0"/>
                            <TextBox Name="_tbMinNodes" Text="{Binding ElementName=_sliderMinNodes, Path=Value}" Width="25" Margin="0,0,15,0"></TextBox>
                            <TextBlock VerticalAlignment="Center" Margin="0,0,5,0">Max</TextBlock>
                            <Slider Name="_sliderMaxNodes" Minimum="{Binding ElementName=_sliderMinNodes, Path=Value}" Maximum="{Binding ElementName=_sliderMinNodes, Path=Maximum}" Width="65" TickFrequency="1" IsSnapToTickEnabled="True" Margin="0,0,5,0"/>
                            <TextBox Name="_tbMaxNodes" Text="{Binding ElementName=_sliderMaxNodes, Path=Value}" Width="25" />
                        </DockPanel>
                        <DockPanel Margin="20,5,0,0">
                            <CheckBox Name="_cbVerbose" IsChecked="True" ToolTip="Shows you what is happening during the algorithm." Margin="0,0,5,0">Verbose mode</CheckBox>
                        </DockPanel>
                        <DockPanel Margin="20,0,0,0" Visibility="Collapsed">
                            <CheckBox Name="_cbAvoidLoop" IsChecked="True" ToolTip="Avoid loop" Margin="0,0,120,0">Avoid loop</CheckBox>
                            <RadioButton Name="_rbDFS" IsChecked="True" ToolTip="Depth first search" Margin="0,0,5,0">DFS</RadioButton>
                            <RadioButton Name="_rbBFS" ToolTip="Breath first search">BFS</RadioButton>
                        </DockPanel>
                    </StackPanel>
                </GroupBox>
            </StackPanel>
        </ScrollViewer>
        <Separator Margin="0,5,0,5"/>
        <WrapPanel HorizontalAlignment="Right">
            <CheckBox Name="_cbOpenSubNetworks" IsChecked="True" Margin="0,0,50,0" VerticalAlignment="Center">Open sub-networks as a new document.</CheckBox>
            <Button IsDefault="True" Margin="0,0,5,0" Click="OK" Content="OK" />
            <Button IsCancel="True" Content="Cancel" />
        </WrapPanel>
    </StackPanel>
</Window>
